package com.aierkeji.b2c.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.aierkeji.b2c.service.AkjOrderService;

@RestController
@RequestMapping(value = "center")
public class AkjCenterController {
	@Autowired
	private AkjOrderService akjOrderService;
	/**
	 * 获取订单列表
	 * @param params
	 * @param request
	 * @return
	 */
	@GetMapping("/getOrderList")
	public Map<String, Object> getOrderList(HttpServletRequest request) {
		String userId = (String)request.getSession().getAttribute("userId");
		String lifeId = (String)request.getSession().getAttribute("lifeId");
		return akjOrderService.getOrderList(userId,lifeId);
	}
	
	
	/**
	 * 取消订单
	 * @param params
	 * @param request
	 * @return
	 */
	@GetMapping("/cancel/{id}")
	public Map<String, Object> cancel(@PathVariable(name="id",required=true)String id,HttpServletRequest request) {
		String userId = (String)request.getSession().getAttribute("userId");
		String lifeId = (String)request.getSession().getAttribute("lifeId");
		return akjOrderService.cancel(id,userId,lifeId);
	}
}
